package com.api.mapper;

import com.api.pojo.Notice;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NoticeMapper {

    @Insert("insert into notice(uid, title, content) value(#{uid}, #{title}, #{content})")
    void create(Notice notice);

    @Delete("delete from notice where id = #{id}")
    void remove(Integer id);

    @Update("update notice set uid = #{uid}, title = #{title}, content = #{content} where id = #{id}")
    void update(Notice notice);

    @Select("select * from notice limit #{pageNo}, #{pageSize}")
    List<Notice> get(Integer pageNo, Integer pageSize);

    @Select("select count(*) from notice")
    Integer count();

    @Select("select * from notice where title like #{title} limit #{pageNo}, #{pageSize}")
    List<Notice> getByTitle(Integer pageNo, Integer pageSize, String title);

    @Select("select count(*) from notice where title like #{title}")
    Integer countByTitle(String title);
}
